<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head th:include="_meta :: header">
  <title>编辑</title>
</head>
<body>

<div class="layui-fluid">
  <div class="layui-row">
    <form class="layui-form form form-horizontal" id="form-sysGenerator-edit" action="#"
          th:action="@{/generator/sysGenerator/edit}" th:object="${sysGenerator}" enctype="multipart/form-data">
      <input type="hidden" name="save" value="true"/>
      <div class="layui-form-item">
        <label class="layui-form-label">
          <span class="x-red">*</span>模块名称
        </label>
        <div class="layui-input-inline">
          <input type="text" name="moduleName" required="" th:value="${sysGenerator.moduleName}" lay-verify="required" placeholder="修改模块名称" id="moduleName"
                 autocomplete="off" class="layui-input">
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">
          <span class="x-red">*</span>表名称
        </label>
        <div class="layui-input-inline">
          <select class="select" name="tableName" id="tableName" th:field="*{tableName}">
            <option th:each="table:${databases}" th:value="${table}" th:text="${table}"></option>
          </select>
        </div>
      </div>



      <div class="layui-form-item">
        <label class="layui-form-label">
          <span class="x-red">*</span>是否忽略前缀
        </label>
        <div class="layui-input-inline">
          <input type="radio" name="ignoreFlag" value="1" title="是"  checked="checked" th:field="*{ignoreFlag}">
          <input type="radio"   name="ignoreFlag" value="0" title="否" th:field="*{ignoreFlag}">
        </div>
      </div>
      <div class="layui-form-item"  id="ignorePrefixDiv">
        <label class="layui-form-label">
          <span class="x-red">*</span>前缀
        </label>
        <div class="layui-input-inline">
          <input type="text" name="ignorePrefix" required="" lay-verify="required" th:value="${sysGenerator.ignorePrefix}" placeholder="修改前缀" id="ignorePrefix"
                 autocomplete="off" class="layui-input">
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">
          <span class="x-red">*</span>是否生成rest接口
        </label>
        <div class="layui-input-inline">
          <input type="radio" name="createRest" value="1" title="是"  checked="checked" th:field="*{createRest}">
          <input type="radio"   name="createRest" value="0" title="否" th:field="*{createRest}">
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">
        </label>
        <button  class="layui-btn" id="subbtn" type="submit" >
          增加
        </button>
        <button  class="layui-btn" id="reset" type="reset" >
          重置
        </button>
      </div>
    </form>
  </div>
</div>
<!--_footer 作为公共模版分离出去-->
<div th:replace="_footer :: footerjs"></div>
<div th:replace="_ueditor :: ueditor"></div>
<!--/_footer 作为公共模版分离出去-->
<!--请在下方写此页面业务相关的脚本-->
<script>
  layui.use(['form', 'layer'],
          function() {
            $ = layui.jquery;
            var form = layui.form,
                    layer = layui.layer;
          });
  $(function(){
    var ignoreFlag = $("input[name=ignoreFlag]:checked").val();
    if(ignoreFlag == 0){
      $("#ignorePrefixDiv").hide();
    }else{
      $("#ignorePrefixDiv").show();
    }
    $("input[name=ignoreFlag]").click(function(){
      var ignoreFlag = $("input[name=ignoreFlag]:checked").val();
      if(ignoreFlag == 0){
        $("#ignorePrefixDiv").hide();
      }else{
        $("#ignorePrefixDiv").show();
      }
    });
  });
  $(function () {
    $("#form-sysGenerator-edit").validate({
      rules: {
        moduleName:
                {
                  required: true,
                },
        tableName:
                {
                  required: true,
                },
        ignoreFlag:
                {
                  required: true,
                },
        ignorePrefix:
                {
                  required: true,
                },
        createRest:
                {
                  required: true,
                },
      },
      onkeyup:false,
      debug
  :
    true,
            success
  :
    "valid",
            submitHandler
  :

    function (form) {
      $(form).ajaxSubmit({
        type: 'POST',
        url: "/generator/sysGenerator/edit",
        success: function (data) {
          if (data.code == "1") {
            selfmsg('编辑成功!', 1, function () {
              var index = parent.layer.getFrameIndex(window.name);
              parent.location.reload();
              parent.layer.close(index);
            });
          } else {
            selfmsg('编辑失败!');
          }
        },
        error: function () {
          selfmsg('编辑异常!', 5);
        }
      });
    }
  })
    ;
  });

  lay('.timeSpace').each(function(){
    laydate.render({
      elem: this
      ,trigger: 'click'
      ,type: 'datetime'
    });
  });

</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>